import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { SGangFightsTeam } from "../../../../../Message/Public/SGangFightsTeam";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { Cache } from "../../../cache/Cache";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
//class GangFightsTeamHistoryCellRenderer
    
    export  class GangFightsTeamHistoryCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._textFormatCenter = GlobalStyle.textFormat1;
            this._textFormatCenter.align = flash.text.TextFormatAlign.CENTER;
            this._textFormatGreenCenter = GlobalStyle.textFormatGreen;
            this._textFormatGreenCenter.align = flash.text.TextFormatAlign.CENTER;
            this._tfRank = ObjCreate.createTextField("", 0, 12, 70, 20, this, this._textFormatCenter);
            this._tfTeamName = ObjCreate.createTextField("", 70, 12, 180, 20, this, this._textFormatCenter);
            this._tfTeamName.addEventListener(flash.events.TextEvent.LINK, this.onLickTeamName);
            this._tfTeamCaptainNam = ObjCreate.createTextField("", 250, 12, 180, 20, this, this._textFormatCenter);
            this._tfScore = ObjCreate.createTextField("", 430, 12, 80, 20, this, this._textFormatCenter);
            this._tfWerfare = ObjCreate.createTextField("", 510, 12, 100, 20, this, this._textFormatCenter);
            this._tfWinPer = ObjCreate.createTextField("", 610, 12, 90, 20, this, this._textFormatCenter);
            this._tfMoney = ObjCreate.createTextField("", 700, 12, 100, 20, this, this._textFormatCenter);
            ObjCreate.createBg(0, 40, 800, 2, this, "SplitLine");
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "sgangfightsteam") 
            {
                this._team = arg1 as SGangFightsTeam;
                this.updateView();
            }
            return;
        }

        /* internal  */onLickTeamName(arg1: Object /* flash.events.TextEvent */): void
        {
            if (this._team) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GangFightsGetTeamOtherInfo, this._team.teamId));
            }
            return;
        }

        /* internal  */updateView(): void
        {
            if (this._team) 
            {
                this._tfRank.text = this._team.rank.toString();
                this._tfTeamName.htmlText = "<a href=\'event: 1\'><u>[" + EntityUtil.getProxyName(this._team.captainEntityId) + "]" + this._team.name.toString() + "</u></a>";
                this._tfTeamCaptainNam.text = this._team.captainName.toString();
                this._tfScore.text = this._team.mark.toString();
                this._tfWerfare.text = this._team.warfare.toString();
                this._tfWinPer.text = this._team.winPer / 100 + "%";
                this._tfMoney.text = this._team.lastMerit.toString();
                if (Cache.instance.gangFights.myInfo && this._team.teamId == Cache.instance.gangFights.myInfo.teamId) 
                {
                    this._tfRank.setTextFormat(this._textFormatGreenCenter);
                    this._tfTeamName.setTextFormat(this._textFormatGreenCenter);
                    this._tfTeamCaptainNam.setTextFormat(this._textFormatGreenCenter);
                    this._tfScore.setTextFormat(this._textFormatGreenCenter);
                    this._tfWerfare.setTextFormat(this._textFormatGreenCenter);
                    this._tfWinPer.setTextFormat(this._textFormatGreenCenter);
                    this._tfMoney.setTextFormat(this._textFormatGreenCenter);
                    if (!this._star) 
                    {
                        this._star = GlobalClass.getBitmap(ImagesConst.ChatGuildMember_star);
                        this._star.x = 0;
                        this._star.y = 10;
                    }
                    this.addChild(this._star);
                }
                else 
                {
                    this._tfRank.setTextFormat(this._textFormatCenter);
                    this._tfTeamName.setTextFormat(this._textFormatCenter);
                    this._tfTeamCaptainNam.setTextFormat(this._textFormatCenter);
                    this._tfScore.setTextFormat(this._textFormatCenter);
                    this._tfWerfare.setTextFormat(this._textFormatCenter);
                    this._tfWinPer.setTextFormat(this._textFormatCenter);
                    this._tfMoney.setTextFormat(this._textFormatCenter);
                    if (this._star && this._star.parent) 
                    {
                        this._star.parent.removeChild(this._star);
                    }
                }
            }
            return;
        }

        /* internal */ /* var */_tfRank: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTeamName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTeamCaptainNam: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWerfare: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWinPer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfMoney: Object /* flash.text.TextField */;

        /* internal */ /* var */_star: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_textFormatCenter: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_textFormatGreenCenter: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_team: SGangFightsTeam;
    }
